package com.javaweb.controller;

/**
 * @desc:
 * @author: Ping
 * @date: 2024/10/22 23:01
 */

import com.javaweb.model.Tag;
import com.javaweb.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * todo: 标签管理模块
 */
@RestController
@RequestMapping("/blog-api/v0.1/tag")
public class TagController {

    @Autowired
    private TagService tagService;

    @GetMapping("/list")
    public ResponseResult<List<Tag>> list(){
        return ResponseResult.ok(tagService.list());
    }

    @PostMapping("/add")
    public ResponseResult add(@RequestBody Tag tag){
        return ResponseResult.ok(tagService.add(tag),"添加成功");
    }

    @GetMapping("/delete")
    public ResponseResult delete(Integer tagId){
        return ResponseResult.ok(tagService.delete(tagId),"添加成功");
    }
}
